﻿@{
    Layout = null;
}

<!DOCTYPE html>

<html>
<head>
    <title>收件箱</title>
    <link href="@Url.Content("~/Areas/User/Css/msg.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Areas/User/Css/pager.css")" rel="stylesheet" type="text/css" />
</head>
<body>
    <!--右侧开始-->
    <div class="rightbar mt10">
        <ul class="tittab">
            <li class='tcurrent'><a hidefocus='' href='#'>全部</a></li>
            <li><a hidefocus='' href='/User/Message/MessageReceiver?type=(int)@SYH.Enum.WebMessageType.议价询盘消息'>议价消息 <span class="red1" id ="yjMsg"></span></a></li>
            <li><a hidefocus='' href='/User/Message/MessageReceiver?type=(int)@SYH.Enum.WebMessageType.报价询盘消息'>报价消息 <span class="red1" id ="bjMsg"></span></a></li>
            <li><a hidefocus='' href='/User/Message/MessageReceiver?type=(int)@SYH.Enum.WebMessageType.采购推送消息'>采购推送 <span class="red1" id ="tsMsg"></span></a></li>
            <li><a hidefocus='' href='/User/Message/MessageReceiver?type=(int)@SYH.Enum.WebMessageType.网站留言消息'>网站留言 <span class="red1" id ="webMsg"></span></a></li>
        </ul>
        <div class="action-bar mt10">
            <p class="fd-left">
                <input name="cbAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="###"
                    onclick="DeleteListMsg();" class="wh01 h17">删除</a></span> <span class="ml30 fd-left">
                        <select name="sel_status" id="sel_status" onchange="setUrl();">
                            <option value="">消息状态</option>+

                            <option value="0">未阅读</option>
                            <option value="1">已阅读</option>
                        </select>
                        <select name="sel_type" id ="sel_type" onchange="setUrl();">
                                <option value="">消息类型</option>
                                <option value="11">议价消息</option>
                                <option value="12">报价消息</option>
                                <option value="13">网站留言</option>
                                <option value="17">采购推送</option>
                                <option value="0">其他消息</option>
                        </select>
                        <input type="checkbox" id="cbx_time" class="mt03 none ml10 mr5" onclick="setUrl();" <%=(MsgTime=="1")?"checked ='checked'":"" %> />三个月以上的留言
                    </span>
            </p>
            <p class="fd-right">
                共 <b><%=RecordCount%></b> 封 <b class="red1"><%=NotReadCount %></b> 封未读</p>
        </div>
        <div class="fd-clear">
        </div>
        <div class="msglists" id="msglists">
             @foreach (var single in @Model.Rows)
             {
                    <dl class="">
                        <dt>
                            <input type="checkbox" name="cbItem" value="<%# Eval("Id") %>" />
                        </dt>
                        <dd class="msgico">
                            <img src="../../images/msgimg"+@single["IsReader"]+".jpg" />
                            <p>
                                <%# Eval("IsReader").ToString()=="1"?"已阅读":"未阅读"%></p>
                        </dd>
                        <dd class="msgcon">
                            <div class="blue">
                                <a>
                                    @*@SYH.Public.BLL.Public_MessagesReceivers.GetReceiverInfo((Int32)single["MailID"])*@
                                    (@Common.EnumHelper.GetEnumDescription((SYH.Enum.WebMessageType)single["TypeId"]))</a><span
                                        class="c-time ml10 mr10">@single["CreateTime"]</span></div>
                            <div class="cur-p" onclick="location.href='/User/Message/MessageDetail?type=receiver&id='+'@single["Id"]';return false;">
                                @single["Title"]
                            </div>
                        </dd>
                        <dd class="close" style="display: none;">
                            <a href="###" onclick='DeleteOneMsg(@single["Id"]);' title="删除">
                            </a>
                        </dd>
                    </dl>
              }
             @if (@Model.Rows.Count == 0)
             {
            <p style="padding: 50px 0 50px 280px;">
                <img src="../../images/no-data.gif" /></p>
            }
        </div>
        <div class="action-bar mt10 border-none">
            <p class="fd-left">
                <input name="cbAll" type="checkbox" value="" class="fd-left mr5 mt3 txt3" />
                <span class="fd-left mr10">全选</span> <span class="gray-btn fd-left ml10"><a href="###"
                    onclick="DeleteListMsg();" class="wh01 h17">删除</a></span>
            </p>
            <p class="fd-right"></p>
        </div>
    </div>
    <script type="text/javascript">
        $(document).ready(function () {
            $("#sel_status").val(<%=MsgStatus %>);
            $("#sel_type").val('<%=MsgType %>');
            $("input[name='cbAll']").click(function () {
                $("input[name='cbItem']").attr("checked", this.checked);
            });
            //getMsgCount();
        });
        //鼠标经过显示背景颜色和关闭按钮
        $(function(){
        $("#msglists>dl").hover(
            function(){
              $(this).children("dd.close").show();
              $(this).addClass("hover");
            },
            function(){
              $(this).children("dd.close").hide();
              $(this).removeClass("hover");
            })
        })

        //删除一条信息
        function DeleteOneMsg(obj){
            var id = obj + ",";
            jQuery.dialogHelper.confirm('您确定要删除吗？', 'DeleteOneExec(\'' + id + '\')');
        }
        function DeleteOneExec(id){
        $.ajax({
                        type: "POST",
                        url: "/User/Message/DeleteList",
                        dataType: "text",
                        data: "id=" + id + "&type=DeleteList" + "&m=" + Math.random(),
                        success: function (msg) {
                            if (msg.indexOf("成功") != -1) {
                                jQuery.dialogHelper.alert("操作成功！", "success", "okSuccess");
                            }
                            else{
                                jQuery.dialogHelper.alert("操作失败！", "alert");
                            }
                            setTimeout("location.href = window.location;", 2000);
                        },
                        error: function () {
                            jQuery.dialogHelper.alert("网络忙，请稍后再试！", "alert");
                        }
                    });
        }
        //批量删除信息
        function DeleteListMsg() {
            var idList = "";
            $("input[name='cbItem']:checked").each(function () {
                idList += $(this).val() + ",";
            });
            if (idList == "") {
                jQuery.dialogHelper.alert("请先选择要删除的信息，然后点击删除！", "alert");
            }
            else {
            jQuery.dialogHelper.confirm('您确定要删除吗？', 'DeleteListExec(\'' + idList + '\')');;
            }
        }
        function DeleteListExec(idList){
        $.ajax({
                        type: "POST",
                        url: "/User/Message/DeleteList",
                        dataType: "text",
                        data: "id=" + idList + "&type=DeleteList" + "&m=" + Math.random(),
                        success: function (msg) {
                            if (msg.indexOf("成功") != -1) {
                                jQuery.dialogHelper.alert("操作成功！", "success", "okSuccess");
                            }
                            else{
                                jQuery.dialogHelper.alert("操作失败！", "alert");
                            }
                            setTimeout("location.href = window.location;", 2000);
                        },
                        error: function () {
                            jQuery.dialogHelper.alert("网络忙，请稍后再试！", "alert");
                        }
                    });
        }
        //删除成功
        function okSuccess() {
            $.dialogHelper.close();
            location.reload();
        }
        //查询
        function setUrl(){
          var url="WebMsgReceiver.aspx";
            var status = $("#sel_status").val();
            var type = $("#sel_type").val();
            var time = $("#cbx_time").attr("checked");
            if(time)
            time ="1";
            else time ="";
            url+="?status="+status+"&type="+type+"&time="+time;
            window.location=url;
        }

        
        function getMsgCount() {
            $.ajax({
                type: "POST",
                url: "/User/Message/Count?callback=?",
                dataType: "json",
                //回调函数返回未读短信数目
                success: function (response) {
                if(response.YjCount!=0){
                    $('#yjMsg').html("(" + response.YjCount + ")");}
                if(response.BjCount!=0){
                    $('#bjMsg').html("(" + response.BjCount + ")");}
                if(response.WebCount!=0){
                    $('#webMsg').html("(" + response.WebCount + ")");}
                if(response.TsCount!=0){
                    $('#tsMsg').html("(" + response.TsCount + ")");}
                },
                error: function (data) {
                                        alert("dfsd");
                }
            });
        }
    </script>
</body>
</html>
